From 76afb8cf11d200b70cb15591a4b5c5384a4cd7ac Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 18 Oct 2002 04:22:19 +0000 Subject: [PATCH] Finish up gpspilot support. Thanx to Ron Parker! --- gpsbabel/README | 5 +- gpsbabel/gpspilot.c | 83 ++++++++++++++++---------------- gpsbabel/reference/gpspilot.pdb | Bin 0 -> 609 bytes gpsbabel/testo | 9 ++++ 4 files changed, 54 insertions(+), 43 deletions(-) create mode 100644 gpsbabel/reference/gpspilot.pdb diff --git a/gpsbabel/README b/gpsbabel/README index 608500c3b..68d86a1d9 100644 --- a/gpsbabel/README +++ b/gpsbabel/README @@ -122,8 +122,9 @@ THE FORMATS GPSPILOT The file format for GPSPILOT (http://www.gpspilot.com) was provided - by Ron Parker. GPSbabel can currently read gpspilot files, but not - write them. + by Ron Parker. The output from this module has been tested with + GPSPilot Tracker v5.05sx, but it is based on reverse-engineering + so it may not work with all versions of all GPSPilot products. MAGNAV diff --git a/gpsbabel/gpspilot.c b/gpsbabel/gpspilot.c index 4d140d78e..aebf30d64 100644 --- a/gpsbabel/gpspilot.c +++ b/gpsbabel/gpspilot.c @@ -110,7 +110,6 @@ data_read(void) wpt_tmp->description = xstrdup(vdata); vdata = vdata + strlen(vdata) + 1; - vdata = vdata + strlen(vdata) + 1; wpt_tmp->shortname = xstrdup(vdata); waypt_add(wpt_tmp); @@ -121,41 +120,40 @@ data_read(void) static void -cetus_writewpt(waypoint *wpt) +gpspilot_writewpt(waypoint *wpt) { struct record *rec; - static int ct; - struct tm *tm; - - rec = xcalloc(sizeof(*rec),1); -#if FIXME - strncpy(rec->ID, wpt->shortname, sizeof(rec->ID)); - rec->ID[sizeof(rec->ID)-1] = 0; - strncpy(rec->name, wpt->description, sizeof(rec->name)); - rec->name[sizeof(rec->name)-1] = 0; - - if (wpt->creation_time) { - tm = gmtime(&wpt->creation_time); - rec->min = tm->tm_min; - rec->hour = tm->tm_hour; - rec->sec = tm->tm_sec; - rec->day = tm->tm_mday; - rec->mon = tm->tm_mon + 1; - rec->year = tm->tm_year - 100; - } else { - rec->min = 0xff; - rec->hour = 0xff; - rec->sec = 0xff; - rec->day = 0xff; - rec->mon = 0xff; - rec->year = 0xff; - } + static int ct = 0; + char *vdata; - pdb_write4(&rec->longitude, wpt->position.longitude.degrees * 10000000.0); - pdb_write4(&rec->latitude, wpt->position.latitude.degrees * 10000000.0); - pdb_write4(&rec->elevation, wpt->position.altitude.altitude_meters * 100.0); -#endif - opdb_rec = new_Record (0, 0, ct++, sizeof(*rec), (const ubyte *)rec); + rec = xcalloc(sizeof(*rec)+46,1); + + be_write32(&rec->longitude, round(wpt->position.longitude.degrees * 3.6e6)); + be_write32(&rec->latitude, round(wpt->position.latitude.degrees * 3.6e6)); + be_write16(&rec->elevation, round(wpt->position.altitude.altitude_meters)); + be_write16(&rec->magvar, 0 ); + + vdata = (char *)rec + sizeof(*rec); + if ( wpt->description ) { + strncpy( vdata, wpt->description, 36 ); + vdata[35] = '\0'; + } + else { + vdata[0] ='\0'; + } + vdata += strlen( vdata ) + 1; + if ( wpt->shortname ) { + strncpy( vdata, wpt->shortname, 9 ); + vdata[8] = '\0'; + } + else { + vdata[0] ='\0'; + } + vdata += strlen( vdata ) + 1; + vdata[0] = '\0'; /* long description - currently unsupported */ + vdata++; + + opdb_rec = new_Record (0, 2, ct++, vdata-(char *)rec, (const ubyte *)rec); if (opdb_rec == NULL) { fatal(MYNAME ": libpdb couldn't create record"); @@ -169,12 +167,9 @@ cetus_writewpt(waypoint *wpt) static void data_write(void) { - int i, ct = waypt_count(); - struct hdr *htable, *bh; - queue *elem, *tmp; - extern queue waypt_head; - waypoint *waypointp; -abort(); + extern queue waypt_head; + queue *elem, *tmp; + if (NULL == (opdb = new_pdb())) { fatal (MYNAME ": new_pdb failed\n"); } @@ -183,11 +178,17 @@ abort(); opdb->name[PDB_DBNAMELEN-1] = 0; opdb->attributes = PDB_ATTR_BACKUP; opdb->ctime = opdb->mtime = time(NULL) + 2082844800U; - opdb->type = MYTYPE; /* poin */ - opdb->creator = MYCREATOR; /* GpLi */ + opdb->type = MYTYPE; + opdb->creator = MYCREATOR; opdb->version = 0; + QUEUE_FOR_EACH(&waypt_head, elem, tmp) { + gpspilot_writewpt((waypoint *)elem); + } + + pdb_Write(opdb, fileno(file_out)); } + ff_vecs_t gpspilot_vecs = { rd_init, wr_init, diff --git a/gpsbabel/reference/gpspilot.pdb b/gpsbabel/reference/gpspilot.pdb new file mode 100644 index 0000000000000000000000000000000000000000..b4c04f0ae539c339cd038eabca110a10b86a733e GIT binary patch literal 609 zcmaKoze~eF6vyMw)5*>GTogpqBuFa=+O$oov?#VBNI|c9O%CHFBxxa=i(5yL4({%{ zwD@aq6918y#^&c3J8iijb}_j37u-uJz;{m>V#7tQ(y73HsML{ZwE<|978fBT-0 zmY)~h{ZUvo`@cS)K>P3p#ia(X0nlC0LC`bMA7RIWs>WY=l8U`@cMu*&;EFn{JI4uR9>!OjVN$qn=I!R4- zB-|JfHKiwj5zptOy>*OCM$|bqyrT*akXrMsjUo`$E|JzS#aZr<>x&sA%=Ka^yZO`H zEw3%47Qwtf@k;KmPSKqAY$j=5*iPhlwUB>fe)zL1Eurav?L}pBJNB7jF)5&-G~0)f zpsiwWYRyQfVBW1#a#v1bM$w6